<%--
  Created by IntelliJ IDEA.
  User: dailyblue
  Date: 2024/1/23
  Time: 09:32
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" isELIgnored="false" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>员工信息</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css"
          integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
</head>
<body>
<c:if test="${empty LIST}">
    <c:redirect url="emp_find_page"/>
</c:if>
<form class="form-inline" action="emp_find_enname" method="post">
    <div class="form-group mx-sm-3 mb-2">
        <label for="enname" class="sr-only">姓名</label>
        <input type="text" class="form-control" id="enname" placeholder="请输入姓名" name="enname">
    </div>
    <%--标记了我进行了搜索--%>
    <input type="hidden" name="type" value="1"/>
    <button type="submit" class="btn btn-primary mb-2">搜索一下</button>
</form>
<table class="table">
    <thead class="thead-dark">
    <tr>
        <th scope="col">序号</th>
        <th scope="col">姓名</th>
        <th scope="col">职位</th>
        <th scope="col">上司</th>
        <th scope="col">入职时间</th>
        <th scope="col">工资</th>
        <th scope="col">奖金</th>
        <th scope="col">部门ID</th>
        <th scope="col">操作</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach var="emp" items="${LIST}" varStatus="j">
        <tr>
            <th scope="row">${j.count}</th>
            <td>${emp.enname}</td>
            <td>${emp.job}</td>
            <td>${emp.mgrEnname}</td>
            <td>${emp.hireDate}</td>
            <td>${emp.sal}</td>
            <td>${emp.comm}</td>
            <td>${emp.dnname}</td>
            <td><a href="#" onclick="deleteEmp(${emp.empno})">删除</a></td>
        </tr>
    </c:forEach>
    </tbody>
    <tfoot>
    <tr>
        <th colspan="8">

            <nav aria-label="Page navigation example">
                <ul class="pagination">
                    <li class="page-item">
                        <a class="page-link" href="#" aria-label="Previous">
                            <span aria-hidden="true">&laquo;</span>
                        </a>
                    </li>
                    <c:forEach var="i" begin="1" end="${PAGENUM}" step="1">
                        <c:choose>
                            <c:when test="${empty TYPE}">
                                <li class="page-item"><a class="page-link" href="emp_find_page?page=${i}">${i}</a></li>
                            </c:when>
                            <c:otherwise>
                                <li class="page-item"><a class="page-link" href="emp_find_enname? type=1&page=${i}">${i}</a></li>
                            </c:otherwise>
                        </c:choose>
                    </c:forEach>
                    <li class="page-item">
                        <a class="page-link" href="#" aria-label="Next">
                            <span aria-hidden="true">&raquo;</span>
                        </a>
                    </li>
                </ul>
            </nav>
        </th>
    </tr>
    </tfoot>
</table>
</body>
</html>
<script>
    function deleteEmp(eid) {
        if (confirm('你确定要删除么？')) {
            location.href = 'emp_delete?id=' + eid;
        }
    }
</script>